package com.dllo.lanou.cookapp;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;

import com.dllo.lanou.cookapp.fragment.AddShowCookFragment;
import com.dllo.lanou.cookapp.fragment.BaseFragment;
import com.dllo.lanou.cookapp.fragment.BookListFragment;
import com.dllo.lanou.cookapp.fragment.PersonInfoFragment;
import com.dllo.lanou.cookapp.fragment.ShowCookFragment;

public class TabHostHome extends AppCompatActivity {
//@Bind(android.R.id.tabhost)
    TabHost mHost;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
      //  ButterKnife.bind(this);
        setContentView(R.layout.activity_tab_host_home);
        mHost = (TabHost) findViewById(android.R.id.tabhost);
        getTab();
        initTabView();

    }
private void getTab()
{
    mHost.setup();
    TabHost.TabSpec home_page = mHost.newTabSpec("home_page");

    View tab_home = getLayoutInflater().inflate(R.layout.tab_home_indicator,null);
    home_page.setIndicator(tab_home);
    home_page.setContent(R.id.homepage);
    mHost.addTab(home_page);

    TabHost.TabSpec page2 = mHost.newTabSpec("page2");
    View tab_cooker = getLayoutInflater().inflate(R.layout.tab_cooker,null);
    page2.setIndicator(tab_cooker);
    page2.setContent(R.id.page2);
    mHost.addTab(page2);

    TabHost.TabSpec add = mHost.newTabSpec("add");
    View tab_add = getLayoutInflater().inflate(R.layout.tab_add,null);
    add.setIndicator(tab_add);
    add.setContent(R.id.add);
    mHost.addTab(add);

    TabHost.TabSpec page3 = mHost.newTabSpec("page3");
    View tab_book = getLayoutInflater().inflate(R.layout.tab_bool,null);
    page3.setIndicator(tab_book);
    page3.setContent(R.id.page3);
    mHost.addTab(page3);

    TabHost.TabSpec page4 = mHost.newTabSpec("page4");
    View tab_info = getLayoutInflater().inflate(R.layout.tab_info_indicator,null);

    page4.setIndicator(tab_info);
    page4.setContent(R.id.page4);
    mHost.addTab(page4);

}
   private void initTabView(){
       FragmentManager manager = getSupportFragmentManager();
       FragmentTransaction fragmentTransaction = manager.beginTransaction();

       fragmentTransaction.replace(R.id.homepage,new BaseFragment());
       fragmentTransaction.replace(R.id.add,new AddShowCookFragment());
       fragmentTransaction.replace(R.id.page2,new BookListFragment());
       fragmentTransaction.replace(R.id.page3,new ShowCookFragment());
       fragmentTransaction.replace(R.id.page4,new PersonInfoFragment());
       fragmentTransaction.commit();
   }

}
